package nickthissen.iracing.common;

import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

import java.util.HashMap;

/**
 * Created by Nick on 9/29/13.
 */
public class Prefs
{
    private SharedPreferences prefs;
    private Context context;

    private Prefs(Context context)
    {
        this.context = context;
        this.prefs = PreferenceManager.getDefaultSharedPreferences(context);
    }

    private static HashMap<Context, Prefs> map = new HashMap<Context, Prefs>();
    public static Prefs get(Context context)
    {
        if (!map.containsKey(context))
        {
            map.put(context, new Prefs(context));
        }
        return map.get(context);
    }

    public boolean getBoolean(int resourceId, boolean defaultValue)
    {
        return prefs.getBoolean(context.getString(resourceId), defaultValue);
    }
}
